package com.rogue.order.seckill.controller;

import com.rogue.common.core.utils.ResultDTO;
import com.rogue.order.seckill.domain.CouponDTO;
import com.rogue.order.seckill.domain.HsCoupon;
import com.rogue.order.seckill.service.HsCouponService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author YeaH
 * @create 2022/4/28 9:53
 */
@RestController
@RequestMapping("/coupon")
public class CouponController {

    @Resource
    private HsCouponService hsCouponService;

    @RequestMapping("/create")
    public ResultDTO create(@RequestBody HsCoupon hsCoupon){
        return ResultDTO.success(hsCouponService.save(hsCoupon));
    }
    @RequestMapping("/update")
    public ResultDTO update(@RequestBody HsCoupon hsCoupon){
        return ResultDTO.success(hsCouponService.updateById(hsCoupon));
    }
    @RequestMapping("/delete/{id}")
    public ResultDTO delete(@PathVariable Long id){
        return ResultDTO.success(hsCouponService.removeById(id));
    }
    @RequestMapping("/get/{id}")
    public ResultDTO get(@PathVariable Long id){
        return ResultDTO.success(hsCouponService.getById(id));
    }
    @RequestMapping("/listCoupon")
    public ResultDTO listCoupon(@RequestBody CouponDTO couponDTO){
        return ResultDTO.success(hsCouponService.listCoupon(couponDTO));
    }
}
